Decoding Method and Apparatus for Infrared Remote Control Commands

ABSTRACT

A decoding method and apparatus capable of automatically adjusting a sampling period is provided. The decoding apparatus decodes a serial code including at least one header pulse and a plurality of data pulses. The decoding apparatus includes a detecting unit for detecting the header pulse to generate an initialization signal, a determining unit for determining a sampling period according to the initialization signal and a pulse width of one of the data pulses, and a decoding unit for decoding the data pulses according to the sampling period.

CROSS REFERENCE TO RELATED PATENT APPLICATION

This patent application is based on Taiwan, R.O.C. patent applicationNo. 97147741 filed on Dec. 9, 2008.

FIELD OF THE INVENTION

The present invention relates to a decoding method and apparatus for aremote control command, and more particularly, to a method and apparatusfor decoding an infrared remote control command by automaticallyadjusting a sampling period.

BACKGROUND OF THE INVENTION

Infrared or radio frequency (RF) technology is commonly employed forremote control apparatus. At present, the infrared remote controlapparatus has advantages of being small in size and having low powerconsumption and low cost and, as such, is widely used. For example, aninfrared remote control apparatus is disclosed in the U.S. Pat. No.4,426,662.

Generally speaking, an infrared remote control system has a transmittingend and a receiving end. When a command is transmitted between the twoends, coding and decoding standards are needed to effectively transmitand identify the command. For example, an infrared remote controldecoding technology applied to the receiving end is disclosed in U.S.Pat. No. 4,426,662. An infrared remote control command has two mainclasses of coding formats—one class is the RC-5 code and the RECS 80code widely used in the European regions, and the other class is the NECcode widely used in the Far Eastern regions.

FIG. 1 shows the conventional NEC coding format of an infrared remotecontrol command. The NEC code applies a pulse width modulation (PWM) andcomprises a header pulse, a 16-bit user code having an 8-bit user codeand an 8-bit user code complement, and a 16-bit data code having an8-bit data code and an 8-bit data code complement. FIG. 2 shows a formatrepresented by binary bits. A duration of about 1.125 milliseconds (ms),of which the pulse width at the high level is about 0.56 ms and thepulse width at the low level is about 0.56 ms, represents a binary bit“0”. Otherwise, a duration of about 2.25 ms, of which the pulse width atthe high level is about 0.56 ms and the pulse width at the low level isabout 1.68 ms, represents a binary bit “1”. In addition, for the headerpulse, a pulse width is about 9 ms at the high level and 4.5 ms at thelow level to make up a duration of about 13.5 ms.

After the transmitting end of the infrared remote control system hastransmitted a remote control command, the receiving end has to decodethe 16-bit data code and the 16-bit user code of the remote controlcommand, so as to identify the meaning represented by the command.Following description takes the foregoing NEC code as an example todescribe a common decoding method. The number of clock cycles between afalling edge and an adjacent rising edge of a waveform of a certain bitof a common serial code, i.e., the number of clock cycles during a lowlevel period, is calculated to identify a corresponding binary command.Suppose a clock cycle is 1 μs, “0” is a duration with a high level of0.56 ms and a low level of 0.56 ms, and “1” is a duration with a highlevel of 0.56 ms and a low level of 1.68 ms. When the number of clockcycles between a failing edge and an adjacent rising edge of thewaveform is 560 (0.56 ms/1 μs), the corresponding bit is decoded as “0”;when the number of clock cycles between a falling edge and an adjacentrising edge of the waveform is 1680 (1.68 ms/1 μs), the correspondingbit is decoded as “1”. Accordingly, the corresponding binary command isdecoded by counting the number of the clock cycles.

It is to be noted that, in the foregoing decoding method, before a valueof a data bit is determined, two intervals of the number of clock cyclessuch as the intervals from 550 to 570 and 1670 to 1690 are defined. Whenthe number of clock cycles between the failing edge and the adjacentrising edge lies within the interval of 550 to 570, it represents thebit value of “0”. Otherwise, when the number of clock cycles between thefailing edge and the adjacent rising edge lies within the interval of1670 to 1690, it represents the bit value of “1”. However, the pulsewaveform may be deformed after the infrared remote control command istransmitted. For example, the pulse width may become larger or smaller.Under such circumstances, the prior decoding method using fixedintervals of the number of clock cycles is not able to obtain a correctbit value of the command.

SUMMARY OF THE INVENTION

One object of the present invention is to provide a decoding method andapparatus capable of generating a proper sampling period for decoding aninfrared remote control command.

In order to achieve the foregoing object, a decoding method applied todecoding a serial code having a header pulse and a plurality of datapulses is provided according to the present invention. The decodingmethod comprises steps of receiving a serial code, detecting the headerpulse of the serial code, determining a sampling period according to apulse width of one of the data pulses when the header pulse is detected,and decoding the data pulses according to the sampling period.

In the step of detecting the header pulse, when the pulse width of apulse width is greater than a predetermined value, the pulse isdetermined as the header pulse. In the step of decoding the data pulsesaccording to the sampling period, when an interval between one of thedata pulses and a next data pulse is less than the predetermined numberof the sampling periods, a first bit value is generated; when theinterval between the data pulse and the next data pulse is greater thanthe predetermined number of the sampling periods, a second bit value isgenerated.

A decoding apparatus for decoding a serial code is provided according tothe present invention. The serial code comprises a header pulse and aplurality of data pulses. The decoding apparatus comprises a detectingunit for detecting the header pulse to generate an initializationsignal, a determining unit for determining a sampling period accordingto the initialization signal and a pulse width of one of the datapulses, and a decoding unit for decoding the data pulses according tothe sampling period.

In the foregoing apparatus, when the pulse width of a pulse is greaterthan a predetermined value, the detecting unit determines that the pulseis the header pulse. Preferably, the foregoing decoding apparatusfurther comprises a memory unit for storing a decoding data outputted bythe decoding unit.

According to the abovementioned decoding apparatus and method, a correctbit value of a command can be obtained even when a pulse waveform of aninfrared remote control command is deformed during transmission.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram of a prior coding format of an infraredremote control command.

FIG. 2 is a schematic diagram of a coding format in FIG. 1, representedby binary bits.

FIG. 3 is a flow chart of a decoding method in accordance with anembodiment of the present invention.

FIG. 4( a) and FIG. 4( b) respectively show schematic diagrams of abinary decoding method in accordance with an embodiment of the presentinvention.

FIG. 5 is a block diagram of a decoding apparatus in accordance with anembodiment of the present invention.

FIG. 6 is a block diagram of a decoding apparatus in accordance with apreferred embodiment of the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

The following description and figures are provided to gain a betterunderstanding of the foregoing object, functions, characteristics andadvantages of embodiments of the present invention.

FIG. 3 is a flow chart of a decoding method in accordance with anembodiment of the present invention. For convenience of discussion, thefollowing description takes the NEC code as an example; however, itshall not be construed as limiting.

After a serial code of an infrared remote control command is received,in Step 301, a header pulse of the serial code is detected. Generallyspeaking, a pulse width of the header pulse of the serial code isseveral times that of a data pulse. Therefore, when the pulse width of apulse of the serial code is detected as being much greater than that ofthe data pulse, the pulse is determined as the header pulse. Forexample, the pulse width of the header pulse of the NEC code is about 9ms, and the pulse width of the data pulse is about 0.56 ms.Consequently, when the pulse width (i.e., the high level period) of apulse is greater than a predetermined value such as 2 ms, the pulse isdetermined as the header pulse.

In Step 302, a sampling period for decoding the serial code iscalculated. When the header pulse is confirmed, the pulse width of thedata pulse following the header pulse is calculated and regarded as thesampling period used for decoding data bits of the serial code. Withrespect to the NEC coding format, since the pulse width of the datapulse during the high level period is fixed, the low level period ismodified to represent a binary bit value of “0” or “1”. Therefore, thesampling period, i.e., the pulse width of each bit of the serial codeduring the high level period, is 0.56 ms. In Step 302, when a waveformof the serial code is deformed during transmission, the pulse width ofthe pulse after being deformed is calculated and regarded as thesampling period for decoding. In this embodiment, the sampling period isobtained by calculating the pulse width of a first data pulse followingthe header pulse.

In Step 303, the data bits (i.e., the data pulses) of the serial codeare decoded via the sampling period obtained in Step 302. That is, thebinary bit value of “0” or “1” represented by a user code or a data codeof the serial code is determined. According to this embodiment, in Step303, the number of sampling periods within an interval between every twopulses of the serial code is detected according to the sampling period.For example, each interval is from a failing edge of a data pulse to arising edge of an adjacent pulse of the serial code. Referring to FIG.4( a), the data bits of the NEC code are taken as an example. When theinterval between two pulses is smaller than 2 sampling periods S_P, thebit represents the binary bit value of “0”. Referring to FIG. 4( b),when the interval between two pulses is greater than or equal to 2sampling periods S_P, the bit represents the binary bit value of “1”. Inanother embodiment, the number of sampling periods between a rising edgeof a data pulse and a rising edge or a failing edge of an adjacent pulseis detected according to the sampling period to determine the bit valuerepresented by the data bit. According to the decoding method of thepresent invention, the sampling period used for decoding is generated bya pulse width actually received. Under normal circumstances, even if awaveform of the infrared remote control serial code is deformed duringtransmission, a pulse of the waveform is deformed in direct proportion.Therefore, by using the sampling period generated according to the pulsewidth of the pulse having been deformed for decoding, a correct decodingresult can still be obtained.

FIG. 5 is a schematic diagram of a decoding apparatus for an infraredremote control command in accordance with an embodiment of the presentinvention. A decoding apparatus 500 according to the present inventioncomprises a detecting unit 510, a determining unit 520 and a decodingunit 530. The detecting unit 510 is for detecting a header pulse of aserial code by detecting whether a pulse width of a pulse of the serialcode is greater than a predetermined value according to a clock signal.When the pulse width is greater than the predetermined value, it isdetermined that the pulse is the header pulse. Taking the NEC code as anexample, the pulse width of the header pulse during the high levelperiod is 9 ms, and the pulse width of the data pulse during the highlevel period is 0.56 ms. Therefore, when a pulse width of a pulse ismuch greater than the pulse width (0.56 ms) of the data pulse, it isdetermined that the pulse is the header pulse. In this embodiment, thepredetermined value is 2 ms. When detecting that a pulse width of apulse is greater than 2 ms, the detecting unit 510 determines that thepulse is the header pulse. After having detected the header pulse, thedetecting unit 510 generates an initialization signal INT_PS forinforming the determining unit 520 and the decoding unit 530.

The determining unit 520 calculates a sampling period for decoding theserial code. Upon receiving the initialization signal INT_PS of thedetecting unit 510, the determining unit 520 begins to calculate thepulse width of a data pulse following the header pulse. The pulse widthis regarded as a sampling period S_P for decoding data bits of theserial code. Taking the NEC code as an example, upon receiving theinitialization signal INT_PS, the determining unit 520 begins tocalculate the pulse width of a pulse of the serial code; that is, a highlevel period of the pulse is calculated. In the standard NEC code, thepulse width is 0.56 ms, and accordingly the determining unit 520calculates and determines a sampling period value of 0.56 ms. However,the infrared remote control command may be disturbed duringtransmission, resulting in a deformation on pulses of the serial code ofthe remote control command. At this point, the determining unit 520still calculates the pulse width of the pulse having been deformed, andthe pulse width is regarded as the sampling period S_P. Therefore, thedetermining unit 520 according to the present invention can calculate apulse width actually received, and the pulse width of the serial code ofthe remote control command is regarded as the sampling period fordecoding.

The decoding unit 530 decodes binary bit values contained in the serialcode. Upon receiving the initialization signal INT_PS from the detectingunit 510, the decoding unit 530 decodes the serial code as receivedaccording to the sampling period S_P calculated by the determining unit520. In an embodiment, the decoding unit 530 detects the number ofsampling periods within an interval between every two pulses accordingto the sampling period S_P to identify a corresponding binary bit value.More specifically, the decoding unit 530 detects the number of samplingperiods between a failing edge of a data pulse and a rising edge of anadjacent pulse of the serial code, or detects the number of samplingperiods between a rising edge of a data pulse and a rising edge or afailing edge of an adjacent pulse, so as to identify a binary bit valuerepresented by each pulse of the serial code. Take the NEC code in FIG.4( a) as an example. When the number of sampling periods during afailing edge of a data pulse to a rising edge of an adjacent pulse issmaller than 2 sampling periods S_P, the pulse represents a binary bitvalue “0”. Referring to FIG. 4( b), when the result is greater than orequal to 2 sampling periods S_P, the pulse represents a binary bit value“1”. In addition, the sampling period used by the decoding unit 530 isgenerated by a pulse width actually received. Therefore, regardless ofwhether a waveform of the serial code is deformed, the decoding unit 530is still capable of accurately decoding the serial code as received.

FIG. 6 is a schematic diagram of a decoding apparatus in accordance witha preferred embodiment of the present invention. In a decoding apparatus600, a detecting unit 610 detects a header pulse of a serial code. Whena pulse width of a pulse as detected is greater than a predeterminedvalue, it is determined that the pulse is the header pulse. A decodingunit 630 and a determining unit 620 is informed via an initializationsignal INT_PS such that the decoding unit 630 is activated to decode theserial code and the determining unit 620 generates a sampling periodaccording to the serial code and a clock signal. The determining unit620 comprises a counter 621 and a latch unit 622. After the detectingunit 610 receives the initialization signal INT_PS, the counter 621calculates the pulse width of a first data pulse following the headerpulse according to the clock signal. That is, the number of clocks ofthe data pulse during the high level period is calculated and providedto the latch unit 622. The latch unit 622 then latches the number ofclocks as a sampling period S_P and outputs the sampling period S_P tothe decoding unit 630. The decoding unit 630 decodes the data pulse ofthe serial code according to the sampling period S_P. At this point, thedecoding unit 630 temporarily stores a bit value generated by decodingthe serial code into a memory unit 640. After the serial code isdecoded, the memory unit 60 outputs a complete command value.

In conclusion, according the present invention, a pulse width of aserial code actually received is applied to generate a sampling period,and the serial code is decoded according to the sampling period, therebysolving the problem of decoding a deformed serial code.

While the invention has been described in terms of what is presentlyconsidered to be the most practical and preferred embodiments, it is tobe understood that the invention needs not to be limited to the aboveembodiments. On the contrary, it is intended to cover variousmodifications and similar arrangements included within the spirit andscope of the appended claims which are to be accorded with the broadestinterpretation so as to encompass all such modifications and similarstructures.

1. A decoding method, for use in a decoder, for decoding a serial codehaving a header pulse and a plurality of data pulses, the decodingmethod comprising steps of: receiving the serial code; detecting theheader pulse of the serial code; determining a sampling period accordingto a pulse width of one of the data pulses after the header pulse isdetected; and decoding the data pulses according to the sampling period.2. The decoding method as claimed in claim 1, wherein the step ofdetecting the header pulse comprises comparing a pulse width of a pulsewith a predetermined value to detect the header pulse.
 3. The decodingmethod as claimed in claim 2, wherein in the step of detecting theheader pulse, the pulse is determined as the header pulse when the pulsewidth of the pulse is greater than the predetermined value.
 4. Thedecoding method as claimed in claim 1, wherein the sampling period isequal to the pulse width of the one of the data pulses.
 5. The decodingmethod as claimed in claim 1, wherein the one data pulse is a first datapulse following the header pulse of the serial code.
 6. The decodingmethod as claimed in claim 1, wherein in the step of decoding the datapulses according to the sampling period, a first bit value is generatedwhen an interval between one of the data pulses and a next adjacent datapulse is less than a predetermined number of sampling periods, and asecond bit value is generated when the interval between the one of thedata pulses and the next adjacent data pulse is greater than thepredetermined number of sampling periods.
 7. The decoding method asclaimed in claim 6, wherein the interval between the one of the datapulses and the next adjacent data pulse is a duration between a failingedge of the one of the data pulses and a rising edge of the nextadjacent data pulse.
 8. A decoding apparatus, for decoding a serial codehaving a header pulse and a plurality of data pulses, the decodingapparatus comprising: a detecting unit, for detecting the header pulseto generate an initialization signal; a determining unit, fordetermining a sampling period according to the initialization signal anda pulse width of one of the data pulses; and a decoding unit, fordecoding the data pulses according to the sampling period.
 9. Thedecoding apparatus as claimed in claim 8, wherein the detecting unitdetects the header pulse according to a predetermined value.
 10. Thedecoding apparatus as claimed in claim 9, wherein when a pulse width ofa pulse is greater than the predetermined value, the detecting unitdetermines the pulse as the header pulse.
 11. The decoding apparatus asclaimed in claim 8, wherein the sampling period is equal to the pulsewidth of the one of the data pulses.
 12. The decoding apparatus asclaimed in claim 8, wherein the determining unit determines the samplingperiod according to a first data pulse following the header pulse of theserial code.
 13. The decoding apparatus as claimed in claim 8, whereinthe decoding unit generates a first bit value when an interval betweenone of the data pulses and a next adjacent data pulse is less than apredetermined number of the sampling periods, and the decoding unitgenerates a second bit value when the interval between the one of thedata pulses and the next adjacent data pulse is greater than thepredetermined number of the sampling periods.
 14. The decoding apparatusas claimed in claim 13, wherein the interval between the one of the datapulses and the next adjacent data pulse is a duration between a failingedge of the one of the data pulses and a rising edge of the nextadjacent data pulse.
 15. The decoding apparatus as claimed in claim 8,further comprising: a memory unit, for storing a decoded data outputtedby the decoding unit.
 16. The decoding apparatus as claimed in claim 8,wherein the determining unit comprises: a counter, for calculating thepulse width of the one of the data pulses according to theinitialization signal and a clock signal; and a latch unit, for latchinga count value generated by the counter.